package cn.edu.sjtu.process_management.config;

import cn.edu.sjtu.process_management.interceptor.HostInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author loumoon
 * @date 2019-11-08 09:47
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    /*@Bean将拦截器实例添加到容器中，从而使用@Value向拦截器注入值*/
    public HostInterceptor getHostInterceptor() {
        return new HostInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(getHostInterceptor()).addPathPatterns("/**");
    }


}
